﻿using System;
using System.Diagnostics;

namespace Crm.Plugins.DuplicateChecker{
    /// <summary>
    /// An Event Log Wrapper.
    /// </summary>
    public static class EventLogger{
        /// <summary>
        /// Writes the message to the application event log and uses the Type as the Log Source.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="type">The type. </param>
        public static void WriteApplicationEvent(string message, Type type){
            string logSource = type.FullName;
            if (!EventLog.SourceExists(logSource)){
                EventLog.CreateEventSource(logSource, "Application");
            }
            EventLog.WriteEntry(logSource, message, EventLogEntryType.Warning);
        }
    }
}